package org.lex.utils;

/**
 * ������ǲ��ɱ��
 * 
 * @author Daniel Liu
 */
public final class Holder<T> {
	private static final String NULL = "null";
	private T value = null;

	public Holder(T value) {
		this.value = value;
	}

	public T get() {
		return this.value;
	}

	@SuppressWarnings("unchecked")
	public boolean equals(Object o) {
		if (null == o)
			return false;
		if (this == o)
			return true;
		if (false == o instanceof Holder)
			return false;
		Holder h = (Holder) o;
		if (null == this.value) {
			if (null == h.value)
				return true;
			else
				return false;
		} else
			return this.value.equals(h.value);
	}

	public String toString() {
		if (null == value)
			return NULL;
		return '[' + value.getClass().getName() + ']' + value.toString();
	}
}
